import request from '@/utils/request.js'

// 获取spu列表数据的接口
// GET /admin/product/{page}/{limit}
export const reqSpuList = (page, limit, category3Id) => request({
  url: `/admin/product/${page}/${limit}`,
  method: 'get',
  params: { category3Id }
})
// 获取spu信息
// /admin/product/getSpuById/{spuId} get
// 获取spu基本信息
export const reqGetSpu = (spuId) => request({
  url: `/admin/product/getSpuById/${spuId}`,
  method: 'get'
})
// 获取品牌信息
// GET /admin/product/baseTrademark/getTrademarkList
// getTrademarkList
export const reqTrademarkList = () => request({
  url: `/admin/product/baseTrademark/getTrademarkList`,
  method: 'get'
})
// 获取spu图片
// GET /admin/product/spuImageList/{spuId}
// getSpuImageList
export const reqSpuImageList = (spuId) => request({
  url: `/admin/product/spuImageList/${spuId}`,
  method: 'get'
})
// 获取平台全部销售属性
// GET /admin/product/baseSaleAttrList
// getBaseSaleAttrList
export const reqBaseSaleAttrList = () => request({
  url: `/admin/product/baseSaleAttrList`,
  method: 'get'
})

// 修改或者添加spu
// /admin/product/saveSpuInfo
// saveSpuInfo

// POST /admin/product/updateSpuInfo
// 更改spu信息

export const reqAddOrUpdateSpu = (spuinfo) => {
  if (spuinfo.id) {
    return request({
      url: `/admin/product/updateSpuInfo`,
      method: 'post',
      data: spuinfo
    })
  } else {
    return request({
      url: `/admin/product/saveSpuInfo`,
      method: 'post',
      data: spuinfo
    })
  }
}

// 删除spu
// /admin/product/deleteSpu/{spuId}
export const reqDeleteSpu = (spuId) => request({
  url: `/admin/product/deleteSpu/${spuId}`,
  method: 'delete'
})

// 获取平台属性
// GET /admin/product/attrInfoList/{category1Id}/{category2Id}/{category3Id}
export const reqGetAttrInfoList = (category1Id, category2Id, category3Id) => request({
  url: `/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`,
  method: 'get'
})

// 获取销售属性
// GET /admin/product/spuSaleAttrList/{spuId}
export const reqGetSaleAttrList = (spuId) => request({
  url: `/admin/product/spuSaleAttrList/${spuId}`,
  method: 'get'
})
// 获取图片
// GET /admin/product/spuImageList/{spuId}
export const reqGetSpuImageList = (spuId) => request({
  url: `/admin/product/spuImageList/${spuId}`,
  method: 'get'
})
// 保存sku
// POST /admin/product/saveSkuInfo
export const reqSaveSkuInfo = (data) => request({
  url: `/admin/product/saveSkuInfo`,
  method: 'post',
  data
})
// 获取sku列表
// GET /admin/product/findBySpuId/{spuId}
export const findBySpuId = (spuId) => request({
  url: `/admin/product/findBySpuId/${spuId}`,
  method: 'get'
})
